package com.area.cth.service.impl;

import com.area.cth.mapper.FeedbackMapper;
import com.area.cth.pojo.Feedback;
import com.area.cth.common.PageBean;
import com.area.cth.service.FeedbackService;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class FeedbackServiceImpl extends ServiceImpl<FeedbackMapper, Feedback> implements FeedbackService {
    @Autowired
    private FeedbackMapper fm;

    @Override
    public void submitFeedback(Feedback feedback) {
        fm.submitFeedback(feedback);
    }

    @Override
    public void deleteFeedback(Integer id) {
        fm.deleteFeedback(id);
    }

    @Override
    public Feedback getFeedbackDetail(Integer id) {
        return fm.getFeedbackDetail(id);
    }

    @Override
    public PageBean<Feedback> feedbackList(Integer pageNo, Integer pageSize) {
        Page<Feedback> page=Page.of(pageNo, pageSize);
        Page<Feedback> p=lambdaQuery()
                .page(page);
        PageBean<Feedback> pb=new PageBean<>();
        pb.setTotal(p.getTotal());
        pb.setPages(p.getPages());
        pb.setRecords(p.getRecords());
        return pb;
    }
}
